package client.behavioral.mediator;

import org.junit.Test;
import uml.behavioral.mediator.Mediator;
import uml.behavioral.mediator.QQGroup;
import uml.behavioral.mediator.QQUser;
import uml.behavioral.mediator.User;

/**
 * 中介者--客户端<br>
 * on 2023/1/2 22:46
 */
public class Client {
    @Test
    public void t() {
        //创建群聊
        Mediator qq1 = new QQGroup("群雄逐鹿");
        Mediator qq2 = new QQGroup("三足鼎立");

        User user, user1, user2;
        user = new QQUser("刘备");
        user1 = new QQUser("曹操");
        user2 = new QQUser("孙策");
        user.joinGroup(qq1);
        user.joinGroup(qq2);
        user1.joinGroup(qq1);
        user.sendMessage(qq1, "我是刘备啊");
        user2.joinGroup(qq2);
        user2.sendMessage(qq2, "我只是偷了个大汉玉玺啊，至于么？");
        user.quit(qq1);
        user2.quit(qq2);
    }

}
